Ext.ns('ru.proburo.oms.air.components.grid');

/**
 * ru.proburo.oms.air.components.grid.RadioColumn
 * @extends Ext.grid.Column
 */
ru.proburo.oms.air.components.grid.RadioColumn = Ext.extend(Ext.grid.Column, {

    /**
     * @private
     * Process and refire events routed from the GridView's processEvent method.
     */
    processEvent: function(name, e, grid, rowIndex, colIndex)
    {
        if(name == 'mousedown')
        {
            var record       = grid.store.getAt(rowIndex);
            var remoteRecord = this.remoteStore.getAt(rowIndex);
            record.set(this.dataIndex, !record.data[this.dataIndex]);
            record.commit();
            remoteRecord.set(this.dataIndex, !record.data[this.dataIndex]);
            remoteRecord.commit();
            
            return false; // Cancel row selection.
        }
        else
        {
            return Ext.grid.ActionColumn.superclass.processEvent.apply(this, arguments);
        }
    },

    renderer: function(v, p, record)
    {
        p.css += ' x-grid3-check-col-td'; 
        return String.format('<div class="x-grid3-check-col{0}">&#160;</div>', v ? '-on' : '');
    }
});